/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * OptimizerResultsFrame.java
 *
 * Created on 2010-11-14, 15:44:33
 */

package nsdh.view;

import nsdh.*;
import javax.swing.table.*;
import javax.swing.*;
import java.util.*;
import nsdh.model.script_models.*;
import javax.swing.event.*;
import java.text.*;

/**
 *
 * @author vtq
 */
public class OptimizerResultsFrame extends javax.swing.JFrame {

    /** Creates new form OptimizerResultsFrame */
    public OptimizerResultsFrame(NsdhController nsdhController) {
        initComponents();
        this.nsdhController = nsdhController;
        decimalFormat =new DecimalFormat("#0.00"); //format wypisywanych liczb w tabelach
        targetFunctionDecimalFormat = new DecimalFormat("#0.00000"); //format wypisywanych funkcji celu
        createInitialPointsTable();
        createPointLTable();
        createPointMTable();
        createPointPTable();
        createOptimizerTextOutputTextPane();

        this.setLocationRelativeTo(null);

        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        closeButton = new javax.swing.JButton();
        initialPointsPanel = new javax.swing.JPanel();
        initialPointsScrollPane = new javax.swing.JScrollPane();
        initialPointsTable = new javax.swing.JTable();
        iterationStepsPanel = new javax.swing.JPanel();
        pointLPanel = new javax.swing.JPanel();
        pointLScrollPane = new javax.swing.JScrollPane();
        pointLTable = new javax.swing.JTable();
        pointMPanel = new javax.swing.JPanel();
        pointMScrollPane = new javax.swing.JScrollPane();
        pointMTable = new javax.swing.JTable();
        pointPPanel = new javax.swing.JPanel();
        pointPScrollPane = new javax.swing.JScrollPane();
        pointPTable = new javax.swing.JTable();
        optimizerTextOutputPanel = new javax.swing.JPanel();
        optimizerTextOutputScrollPane = new javax.swing.JScrollPane();
        optimizerTextOutputTextPane = new javax.swing.JTextPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Wyniki optymalizacji");

        closeButton.setText("Zamknij");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        initialPointsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Punkty inicjalizacyjne tablicy A (w tym punkt poczatkowy)"));

        initialPointsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        initialPointsScrollPane.setViewportView(initialPointsTable);

        javax.swing.GroupLayout initialPointsPanelLayout = new javax.swing.GroupLayout(initialPointsPanel);
        initialPointsPanel.setLayout(initialPointsPanelLayout);
        initialPointsPanelLayout.setHorizontalGroup(
            initialPointsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(initialPointsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(initialPointsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 915, Short.MAX_VALUE)
                .addContainerGap())
        );
        initialPointsPanelLayout.setVerticalGroup(
            initialPointsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(initialPointsPanelLayout.createSequentialGroup()
                .addComponent(initialPointsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        iterationStepsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Kolejne kroki iteracji"));

        pointLPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Punkt L"));

        pointLTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        pointLScrollPane.setViewportView(pointLTable);

        javax.swing.GroupLayout pointLPanelLayout = new javax.swing.GroupLayout(pointLPanel);
        pointLPanel.setLayout(pointLPanelLayout);
        pointLPanelLayout.setHorizontalGroup(
            pointLPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pointLPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pointLScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 881, Short.MAX_VALUE)
                .addContainerGap())
        );
        pointLPanelLayout.setVerticalGroup(
            pointLPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pointLPanelLayout.createSequentialGroup()
                .addComponent(pointLScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pointMPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Punkt M"));

        pointMTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        pointMScrollPane.setViewportView(pointMTable);

        javax.swing.GroupLayout pointMPanelLayout = new javax.swing.GroupLayout(pointMPanel);
        pointMPanel.setLayout(pointMPanelLayout);
        pointMPanelLayout.setHorizontalGroup(
            pointMPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pointMPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pointMScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 881, Short.MAX_VALUE)
                .addContainerGap())
        );
        pointMPanelLayout.setVerticalGroup(
            pointMPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pointMPanelLayout.createSequentialGroup()
                .addComponent(pointMScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
                .addContainerGap())
        );

        pointPPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Punkt P"));

        pointPTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        pointPScrollPane.setViewportView(pointPTable);

        javax.swing.GroupLayout pointPPanelLayout = new javax.swing.GroupLayout(pointPPanel);
        pointPPanel.setLayout(pointPPanelLayout);
        pointPPanelLayout.setHorizontalGroup(
            pointPPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pointPPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pointPScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 881, Short.MAX_VALUE)
                .addContainerGap())
        );
        pointPPanelLayout.setVerticalGroup(
            pointPPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pointPPanelLayout.createSequentialGroup()
                .addComponent(pointPScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout iterationStepsPanelLayout = new javax.swing.GroupLayout(iterationStepsPanel);
        iterationStepsPanel.setLayout(iterationStepsPanelLayout);
        iterationStepsPanelLayout.setHorizontalGroup(
            iterationStepsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(iterationStepsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(iterationStepsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pointMPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pointLPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pointPPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        iterationStepsPanelLayout.setVerticalGroup(
            iterationStepsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(iterationStepsPanelLayout.createSequentialGroup()
                .addComponent(pointLPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointMPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointPPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        optimizerTextOutputPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Wyjscie optymalizatora"));

        optimizerTextOutputScrollPane.setViewportView(optimizerTextOutputTextPane);

        javax.swing.GroupLayout optimizerTextOutputPanelLayout = new javax.swing.GroupLayout(optimizerTextOutputPanel);
        optimizerTextOutputPanel.setLayout(optimizerTextOutputPanelLayout);
        optimizerTextOutputPanelLayout.setHorizontalGroup(
            optimizerTextOutputPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optimizerTextOutputPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(optimizerTextOutputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 915, Short.MAX_VALUE)
                .addContainerGap())
        );
        optimizerTextOutputPanelLayout.setVerticalGroup(
            optimizerTextOutputPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optimizerTextOutputPanelLayout.createSequentialGroup()
                .addComponent(optimizerTextOutputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(434, 434, 434)
                        .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(initialPointsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(optimizerTextOutputPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(iterationStepsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(initialPointsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(iterationStepsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(optimizerTextOutputPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(closeButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
        dispose();
    }//GEN-LAST:event_closeButtonActionPerformed

    private void createInitialPointsTable(){


        //utworz nazwy kolumn #,f.celu,zmienne
        ArrayList<String> columnNameArray = new ArrayList<String>();
        columnNameArray.add("#");
        columnNameArray.add("F.celu");

        //sortowanie kluczy
        Object variableKeyObjectArray[] = nsdhController.optimizer.optimizerInput.variableList.keySet().toArray();
        String variableKeyArray[] = Arrays.copyOf(variableKeyObjectArray, variableKeyObjectArray.length, String[].class);
        java.util.Arrays.sort(variableKeyArray);
        Object functionArguementsKeyObjectArray[] = nsdhController.optimizer.optimizerInput.functionArgumentList.keySet().toArray();
        String functionArguementsKeyArray[] = Arrays.copyOf(functionArguementsKeyObjectArray, functionArguementsKeyObjectArray.length, String[].class);
        java.util.Arrays.sort(functionArguementsKeyArray);

        for(String variableName: variableKeyArray){
            columnNameArray.add(variableName);
        }
        for(String functionArguementName: functionArguementsKeyArray){
            columnNameArray.add(functionArguementName);
        }

        //zainicjalizuj model tabeli
        initialPointsTable.setModel(new DefaultTableModel(columnNameArray.toArray(),0));
        DefaultTableModel model = (DefaultTableModel)initialPointsTable.getModel();


        for (int pointNumber=0; pointNumber<nsdhController.optimizer.optimizerOutput.initialRandomPointsList.size(); pointNumber++){
            
            ArrayList<String> rowArray = new ArrayList<String>();
            
            rowArray.add(String.valueOf(pointNumber));
            rowArray.add(targetFunctionDecimalFormat.format(nsdhController.optimizer.optimizerOutput.initialRandomPointsList.get(pointNumber).targetFunctionValue));

            for (String variableKey: variableKeyArray){
                    rowArray.add(decimalFormat.format(nsdhController.optimizer.optimizerOutput.initialRandomPointsList.get(pointNumber).optimizationVariableToValueList.get(variableKey)));
                }
            for (String arguementKey: functionArguementsKeyArray){
                rowArray.add(decimalFormat.format(nsdhController.optimizer.optimizerOutput.initialRandomPointsList.get(pointNumber).targetFunctionArguementToValueList.get(arguementKey)));
            }

            model.addRow(rowArray.toArray());
            
        }

    }

    private void createPointLTable(){

        //utworz nazwy kolumn #,f.celu,zmienne
        ArrayList<String> columnNameArray = new ArrayList<String>();
        columnNameArray.add("Krok");
        columnNameArray.add("F.celu");

        //sortowanie kluczy
        Object variableKeyObjectArray[] = nsdhController.optimizer.optimizerInput.variableList.keySet().toArray();
        String variableKeyArray[] = Arrays.copyOf(variableKeyObjectArray, variableKeyObjectArray.length, String[].class);
        java.util.Arrays.sort(variableKeyArray);
        Object functionArguementsKeyObjectArray[] = nsdhController.optimizer.optimizerInput.functionArgumentList.keySet().toArray();
        String functionArguementsKeyArray[] = Arrays.copyOf(functionArguementsKeyObjectArray, functionArguementsKeyObjectArray.length, String[].class);
        java.util.Arrays.sort(functionArguementsKeyArray);

        for(String variableName: variableKeyArray){
            columnNameArray.add(variableName);
        }
        for(String functionArguementName: functionArguementsKeyArray){
            columnNameArray.add(functionArguementName);
        }
        

        //zainicjalizuj model tabeli
        pointLTable.setModel(new DefaultTableModel(columnNameArray.toArray(),0));
        DefaultTableModel model = (DefaultTableModel)pointLTable.getModel();

        //dodaj wiersze do tabeli z wynikow optymalizatora
        for (int iterationNumber=0; iterationNumber<nsdhController.optimizer.optimizerOutput.iterationResultsList.size(); iterationNumber++){

            ArrayList<String> rowArray = new ArrayList<String>();

            //numer iteracji
            rowArray.add(String.valueOf(iterationNumber));
            //wartosci L
            if(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_L==null){
                rowArray.add("");
                rowArray.add("");
                rowArray.add("");
            }else{
                rowArray.add(targetFunctionDecimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_L.targetFunctionValue));

                for (String variableKey: variableKeyArray){
                    rowArray.add(decimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_L.optimizationVariableToValueList.get(variableKey)));
                }
                for (String arguementKey: functionArguementsKeyArray){
                    rowArray.add(decimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_L.targetFunctionArguementToValueList.get(arguementKey)));
                }
            }

            model.addRow(rowArray.toArray());

        }

    }


    private void createPointMTable(){

        //utworz nazwy kolumn #,f.celu,zmienne
        ArrayList<String> columnNameArray = new ArrayList<String>();
        columnNameArray.add("Krok");
        columnNameArray.add("F.celu");

        //sortowanie kluczy
        Object variableKeyObjectArray[] = nsdhController.optimizer.optimizerInput.variableList.keySet().toArray();
        String variableKeyArray[] = Arrays.copyOf(variableKeyObjectArray, variableKeyObjectArray.length, String[].class);
        java.util.Arrays.sort(variableKeyArray);
        Object functionArguementsKeyObjectArray[] = nsdhController.optimizer.optimizerInput.functionArgumentList.keySet().toArray();
        String functionArguementsKeyArray[] = Arrays.copyOf(functionArguementsKeyObjectArray, functionArguementsKeyObjectArray.length, String[].class);
        java.util.Arrays.sort(functionArguementsKeyArray);

        for(String variableName: variableKeyArray){
            columnNameArray.add(variableName);
        }
        for(String functionArguementName: functionArguementsKeyArray){
            columnNameArray.add(functionArguementName);
        }


        //zainicjalizuj model tabeli
        pointMTable.setModel(new DefaultTableModel(columnNameArray.toArray(),0));
        DefaultTableModel model = (DefaultTableModel)pointMTable.getModel();

        //dodaj wiersze do tabeli z wynikow optymalizatora
        for (int iterationNumber=0; iterationNumber<nsdhController.optimizer.optimizerOutput.iterationResultsList.size(); iterationNumber++){

            ArrayList<String> rowArray = new ArrayList<String>();

            //numer iteracji
            rowArray.add(String.valueOf(iterationNumber));
            //wartosci L
            if(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_M==null){
                rowArray.add("");
                rowArray.add("");
                rowArray.add("");
            }else{
                rowArray.add(targetFunctionDecimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_M.targetFunctionValue));
                for (String variableKey: variableKeyArray){
                    rowArray.add(decimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_M.optimizationVariableToValueList.get(variableKey)));
                }
                for (String arguementKey: functionArguementsKeyArray){
                    rowArray.add(decimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_M.targetFunctionArguementToValueList.get(arguementKey)));
                }
            }

            model.addRow(rowArray.toArray());

        }

    }


    private void createPointPTable(){

        //utworz nazwy kolumn #,f.celu,zmienne
        ArrayList<String> columnNameArray = new ArrayList<String>();
        columnNameArray.add("Krok");
        columnNameArray.add("F.celu");

        //sortowanie kluczy
        Object variableKeyObjectArray[] = nsdhController.optimizer.optimizerInput.variableList.keySet().toArray();
        String variableKeyArray[] = Arrays.copyOf(variableKeyObjectArray, variableKeyObjectArray.length, String[].class);
        java.util.Arrays.sort(variableKeyArray);
        Object functionArguementsKeyObjectArray[] = nsdhController.optimizer.optimizerInput.functionArgumentList.keySet().toArray();
        String functionArguementsKeyArray[] = Arrays.copyOf(functionArguementsKeyObjectArray, functionArguementsKeyObjectArray.length, String[].class);
        java.util.Arrays.sort(functionArguementsKeyArray);

        for(String variableName: variableKeyArray){
            columnNameArray.add(variableName);
        }
        for(String functionArguementName: functionArguementsKeyArray){
            columnNameArray.add(functionArguementName);
        }


        //zainicjalizuj model tabeli
        pointPTable.setModel(new DefaultTableModel(columnNameArray.toArray(),0));
        DefaultTableModel model = (DefaultTableModel)pointPTable.getModel();

        //dodaj wiersze do tabeli z wynikow optymalizatora
        for (int iterationNumber=0; iterationNumber<nsdhController.optimizer.optimizerOutput.iterationResultsList.size(); iterationNumber++){

            ArrayList<String> rowArray = new ArrayList<String>();

            //numer iteracji
            rowArray.add(String.valueOf(iterationNumber));
            //wartosci L
            if(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_M==null){
                rowArray.add("");
                rowArray.add("");
                rowArray.add("");
            }else{
                rowArray.add(targetFunctionDecimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_P.targetFunctionValue));
                for (String variableKey: variableKeyArray){
                    rowArray.add(decimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_P.optimizationVariableToValueList.get(variableKey)));
                }
                for (String arguementKey: functionArguementsKeyArray){
                    rowArray.add(decimalFormat.format(nsdhController.optimizer.optimizerOutput.iterationResultsList.get(iterationNumber).crs2_P.targetFunctionArguementToValueList.get(arguementKey)));
                }
            }

            model.addRow(rowArray.toArray());

        }

    }


    private void createOptimizerTextOutputTextPane(){

        optimizerTextOutputTextPane.setText(nsdhController.optimizer.optimizerOutput.textOutput);

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton closeButton;
    private javax.swing.JPanel initialPointsPanel;
    private javax.swing.JScrollPane initialPointsScrollPane;
    private javax.swing.JTable initialPointsTable;
    private javax.swing.JPanel iterationStepsPanel;
    private javax.swing.JPanel optimizerTextOutputPanel;
    private javax.swing.JScrollPane optimizerTextOutputScrollPane;
    private javax.swing.JTextPane optimizerTextOutputTextPane;
    private javax.swing.JPanel pointLPanel;
    private javax.swing.JScrollPane pointLScrollPane;
    private javax.swing.JTable pointLTable;
    private javax.swing.JPanel pointMPanel;
    private javax.swing.JScrollPane pointMScrollPane;
    private javax.swing.JTable pointMTable;
    private javax.swing.JPanel pointPPanel;
    private javax.swing.JScrollPane pointPScrollPane;
    private javax.swing.JTable pointPTable;
    // End of variables declaration//GEN-END:variables

    private NsdhController nsdhController;
    private DecimalFormat decimalFormat;
    private DecimalFormat targetFunctionDecimalFormat;

}
